
from amplitude.emailer import Emailer

class Error(Emailer):
    
    def error_mail(self, req, exc):
        """sends a mail to the site admin with info about the exception.
        Params: req -- the request
                exc -- an HTML representation of the exception (usu. provided by mako.exceptions.html_error_template().render())
        """
        from email.mime.text import MIMEText
        msgbody = self.render('/email/error.mako', exc=exc, req=req)
        msg = MIMEText(msgbody, 'html')
        msg['From'] = self.config.Email.fromaddr
        msg['To'] = self.config.Email.admin or self.config.Site.admin
        msg['Subject'] = "[%s] Error in %s" % (self.config.Site.name, req.uri)
        return msg
        
